package test_condition

import "fmt"

func Do() {
	fmt.Println("条件语句")

	//if分支判断
	if true {
		fmt.Println("if分支true")
	} else {
		fmt.Println("if分支false")
	}
	//switch分支判断
	a := 1
	switch a {
	case 1:
		fmt.Println("switch击中1")
		// break //可忽略，自动break
		fallthrough
	case 2:
		fmt.Println("switch击中2")
	case 3:
		fmt.Println("switch击中2")
	default:
		fmt.Println("switch语句结束")
	}

	//for循环
	for i := 0; i < 10; i++ {
		if i > 5 {
			break
		} else {
			fmt.Println("for循环测试 ", i)
		}
	}

	//range
	strings := []string{"str1", "str2"}
	for _, v := range strings {
		fmt.Print(v + " ")
	}
	fmt.Println()
	for _, v := range "abcd" {
		fmt.Print(v)
	}
	fmt.Println()
	m1 := map[string]string{"a": "abc", "d": "def"}
	for k, v := range m1 {
		fmt.Println(k, v)
	}

	//goto
	i := 0
LOOP:
	for ; i < 10; i++ {
		if i == 5 {
			i = 8
			goto LOOP
		}
		fmt.Println("goto测试 ", i)
	}
	//while循环(无)
	//select
}
